import {findSongsByStyle, findSongByTitle, randomGenerateSongsByNum} from "@/Network/songApi";
import {
    findAllUserSongsByUserOrderByUpdateTimeDesc,
    findUserById,
    hotListenCountRecommend,
    itemRecommend
} from "@/Network/userApi";
import {ref} from "vue";
import {itemRecSongs} from "@/store/songStore";
import type {res} from "@/store/dataType";

export async function getItemRecSongs(userId){
    let res1:res<any> = await itemRecommend(userId)
    let songs = ref([])
    for(let i=0;i<res1.data.length;i++){
        let songTitle = {
            title:res1.data[i].song
        }
        let res2:res<any> = await findSongByTitle(songTitle)
        songs.value.push(res2.data)
    }
    console.log("itemRecSongs.value:")
    console.log(itemRecSongs.value)
    return songs.value
}

export async function getHotListenCountSongs(){
    let res1:res<any> = await hotListenCountRecommend()
    let songs = ref([])
    for(let i=0;i<res1.data.length;i++){
        let songTitle = {
            title:res1.data[i].title
        }
        let res2:res<any> = await findSongByTitle(songTitle)
        songs.value.push(res2.data)
    }
    console.log("hotListenCountRecommend:")
    return songs.value
}